package saima;

import java.util.*;

/**
 * @author MaoLin Wang
 * @date 2020/4/1623:58
 */
public class 采购单 {
    public static void main(String[] args) {
        int total;
        int buyCount;
        List<Integer>price;
        Map<String,Integer>map;
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNextInt()){
            total=scanner.nextInt();
            buyCount=scanner.nextInt();
            price=new LinkedList<Integer>();
            map=new HashMap<String, Integer>();
            for (int i = 0; i < total; i++) {
                price.add(scanner.nextInt());
            }
            for (int i = 0; i < buyCount; i++) {
                String name=scanner.next();
                if (map.containsKey(name)){
                    map.put(name,map.get(name)+1);
                }else {
                    map.put(name,1);
                }
            }
            Collection<Integer> values = map.values();
            Object[] objects =  values.toArray();
            Integer[]arr=new Integer[objects.length];
            for (int i = 0; i < objects.length; i++) {
                arr[i]=(Integer) objects[i];
            }
            Arrays.sort(arr, new Comparator<Integer>() {
                public int compare(Integer o1, Integer o2) {
                    return  o1- o2>0?-1:1;
                }
            });
            Object[] priceArr = price.toArray();
            Integer[]priceArr2=new Integer[priceArr.length];
            for (int i = 0; i < priceArr.length; i++) {
                priceArr2[i]= (Integer) priceArr[i];
            }
            Arrays.sort(priceArr2);
            int min=0;
            int max=0;

            int priceIndex=0;
            int pricePostIndex=priceArr2.length-1;
            for (int i = 0; i < arr.length; i++) {
                min=min+arr[i]*priceArr2[priceIndex];
                max=max+arr[i]*priceArr2[pricePostIndex];
                priceIndex++;
                pricePostIndex--;
            }
            System.out.println(min+" "+max);



        }

    }
}
